package com.jyw.seed.controller;

import com.jyw.seed.config.Resource;
import com.jyw.seed.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

	private final Resource resource;

	@Autowired
	public UserController(Resource resource) {
		this.resource = resource;
	}

	@RequestMapping("/get")
	public User getUser(){
		return new User("jyw","1234567");
	}

	@RequestMapping("/get-website")
	public Map getWebsite(){
		Map<String,String> resultMap = new HashMap<>(2);
		resultMap.put("website",resource.getWebsite());
		resultMap.put("language",resource.getLanguage());
		return resultMap;
	}

	@RequestMapping("/err")
	public ResponseEntity<?> ajaxError(){
		int a = 1/0;
		return new ResponseEntity<>(HttpStatus.OK);
	}


}
